/*
 * Author: http://www.redwolf-soft.com
 * All Rights Reserved
 * 
 * 2013.11
 *   
 * */
package com.redwolfsoft.libshoppingserver.shoppingcenter;

import net.sf.json.JSONObject;



public class ShoppingCenterInfo {
	public final static String TAG = "ShoppingCenterInfo";
	
	public String id = null;
	public String name = null;//商场名称
	public String subname = null;//商场子名称，如复兴门店，已废弃
	public boolean isFavorited = false;
	
	
	public String mLogoUrl = null;//logo，用于收藏
	//public List<ShoppingCenterBrandInfo> BrandList = null;
	//public List<ShoppingCenterShopInfo> ShopList = null;
	
	public double longititude = 0;
	public double latitude = 0;
	
	public String address = null;
	public String email = null;
	public String tel = null;
	public String serviceSlot = null;
	
	/**
	 * 用于收藏
	 * */
	public ShoppingCenterInfo(String id,String name,String logoUrl)
	{
		this.id=id;
		this.name = name;
		this.mLogoUrl = logoUrl;
	}
	
	public ShoppingCenterInfo(String id,String name,String subname,
			boolean isFavorited
			//,List<ShoppingCenterBrandInfo> list,
			//List<ShoppingCenterShopInfo> ShopList
			)
	{
		this.id=id;
		this.name  = name;
		this.subname = subname;
		this.isFavorited = isFavorited;
	
		//this.BrandList = list;
		//this.ShopList = ShopList;
	}
	
	public ShoppingCenterInfo(JSONObject obj)
	{
		if(obj==null)
		{
			//Log.w(TAG, "JSONObject is null");
			System.out.println("JSONObject is null");
			return;
		}
		//try {	
		id = obj.getString("id");
			name = obj.getString("name");
			subname = obj.optString("subname");
			isFavorited = obj.optBoolean("isFavorited");
	
			mLogoUrl=obj.optString("mLogoUrl");
			longititude = obj.optDouble("longititude");
			latitude = obj.optDouble("latitude");
			
			
			address = obj.optString("address");
			email = obj.optString("email");
			tel = obj.optString("tel");
			serviceSlot = obj.optString("serviceSlot");
			/*
			BrandList = new ArrayList<ShoppingCenterBrandInfo>();
			JSONArray array1 = obj.getJSONArray("mBrandShopInfoList");
			for(int i=0;i<array1.size();i++)
			{				
				BrandList.add(new ShoppingCenterBrandInfo(array1.getJSONObject(i)));
			}
			
			ShopList = new ArrayList<ShoppingCenterShopInfo>();
			JSONArray array2 = obj.getJSONArray("ShopList");
			for(int i=0;i<array1.size();i++)
			{				
				ShopList.add(new ShoppingCenterShopInfo(array2.getJSONObject(i)));
			}	*/	
			
		/*} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
	}
	public JSONObject toJsonObject()
	{
		JSONObject obj = new JSONObject();
		//JSONObject obj2 = new JSONObject();
		//try {
		obj.put("id", id);
			obj.put("name", name);
			obj.put("subname", subname);
			obj.put("isFavorited", isFavorited);
		
			obj.put("mLogoUrl", mLogoUrl);
			obj.put("longititude", longititude);
			obj.put("latitude", latitude);
			
			obj.put("address", address);
			obj.put("email", email);
			obj.put("tel", tel);
			obj.put("serviceSlot", serviceSlot);
			/*
			JSONArray array1 = new JSONArray();
			for(int i=0;i<BrandList.size();i++)
			{
				array1.add(i,BrandList.get(i).toJsonObject());
			}
			obj.put("BrandList", array1);
			
			JSONArray array2 = new JSONArray();
			for(int i=0;i<ShopList.size();i++)
			{
				array2.add(i,ShopList.get(i).toJsonObject());
			}
			obj.put("ShopList", array2);
			*/
			//obj2.put(TAG, obj);
		/*} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}*/
		return obj;
		
	}
}
